const observers = new Set();
const observe = func => observers.add(func);
const observable = obj => new Proxy(obj, {
    set: function (obj, prop, value, receiver) {
        const result = Reflect.set(obj, prop, value, receiver);
        observers.forEach(observer => observer({
            obj,
            prop,
            value
        }));
        return result;
    }
});

const obj = observable({ name: 'demo' });
const observer1 = function () {
    const { obj, prop, value } = arguments[0];
    console.log(`set ${prop} of ${obj.name} to ${value}`);
}
observe(observer1);
obj.a = 1;
obj.b = 'hello';
